From c21cde9010175e2355df17d4e81fedd6020603f8 Mon Sep 17 00:00:00 2001
From: Fabrice Fontaine <fontaine.fabrice@gmail.com>
Date: Sat, 14 May 2022 00:03:51 +0200
Subject: [PATCH] fix build with libressl >= 3.5.0

Fix the following build failure with libressl >= 3.5.0:

crypto-openssl-10.cpp:78:18: error: field 'ctx' has incomplete type 'HMAC_CTX' {aka 'hmac_ctx_st'}
   78 |         HMAC_CTX ctx;
      |                  ^~~

Fixes:
 - http://autobuild.buildroot.org/results/98747d470c2ad59280934e160d24bd3fdad1503c

Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
[Upstream status: https://github.com/AGWA/git-crypt/pull/249]
---
 crypto-openssl-10.cpp | 4 +++-
 crypto-openssl-11.cpp | 4 +++-
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/crypto-openssl-10.cpp b/crypto-openssl-10.cpp
index f0f2c53..a7a5d52 100644
--- a/crypto-openssl-10.cpp
+++ b/crypto-openssl-10.cpp
@@ -29,8 +29,10 @@
  */
 
 #include <openssl/opensslconf.h>
+#include <openssl/opensslv.h>
 
-#if !defined(OPENSSL_API_COMPAT)
+#if !defined(OPENSSL_API_COMPAT) && \
+	!(defined(LIBRESSL_VERSION_NUMBER) && LIBRESSL_VERSION_NUMBER >= 0x30500000L)
 
 #include "crypto.hpp"
 #include "key.hpp"
diff --git a/crypto-openssl-11.cpp b/crypto-openssl-11.cpp
index adf03bb..32c2483 100644
--- a/crypto-openssl-11.cpp
+++ b/crypto-openssl-11.cpp
@@ -29,8 +29,10 @@
  */
 
 #include <openssl/opensslconf.h>
+#include <openssl/opensslv.h>
 
-#if defined(OPENSSL_API_COMPAT)
+#if defined(OPENSSL_API_COMPAT) || \
+	(defined(LIBRESSL_VERSION_NUMBER) && LIBRESSL_VERSION_NUMBER >= 0x30500000L)
 
 #include "crypto.hpp"
 #include "key.hpp"
-- 
2.35.1

